package com.jic.manager.controller.manage.sys;

import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.common.base.vo.RestResult;
import com.jic.manager.entity.SysRoleMenuVerify;
import com.jic.manager.request.SysRoleMenuVerifyRequest;
import com.jic.manager.service.SysRoleMenuVerifyService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("sysRoleMenuVerify")
public class SysRoleMenuVerifyController {

    @Resource
    private SysRoleMenuVerifyService sysRoleMenuVerifyService;


    @ApiOperation("角色操作")
    @PostMapping("/addSysRoleMenuVerify")
    public RestResult<String> addSysRoleMenuVerify(@RequestBody SysRoleMenuVerifyRequest sysRoleMenuVerifyRequest){
        try{
            sysRoleMenuVerifyService.insert(sysRoleMenuVerifyRequest);
           return RestResult.success("成功");
        }catch (Exception e){
            log.error("Manager sysRoleMenuVerify editSysRoleMenuVerify error：",e);
            return RestResult.error("9999","系统异常，操作失败");
        }
    }



    /**
     * 查询列表
     * @param request
     * @return
     */
    @ApiOperation("查询列表")
    @PostMapping("/queryPage")
    public RestResult<PageResult<SysRoleMenuVerify>> queryPage(@RequestBody SysRoleMenuVerifyRequest request){
        try{   Page page = new Page();
            page.setLimit(request.getLimit());
            page.setStart(request.getStart());
            PageResult<SysRoleMenuVerify> result =sysRoleMenuVerifyService.queryPage(request, page);
            return RestResult.success(result);
        }catch (Exception e){
            log.error("Manager sysRoleMenuVerify queryPage error：",e);
            return RestResult.error("9999","系统异常，查询列表失败");
        }
    }



}
